/**
 * @description   定义mock
 * @param  { String }
 * @returns 可根据情况使用随机数据
 */
import { resultSuccess } from '../_util';
import { MockMethod } from 'vite-plugin-mock';
import DomainJson from './DomainJson.json';
import UnitJson from './UnitJson.json';
import TreeJson from './TreeJson.json';
import ParentJson from './ParentJson.json';
import RegionsJson from './RegionsJson.json';

export default [
  {
    url: '/mock-api/comRegion/unitregionrdata/1',
    timeout: 100,
    method: 'get',
    response: ({}) => {
      return resultSuccess(DomainJson);
    },
  },
  {
    url: '/mock-api/comUnit/getUnitid/103645',
    timeout: 100,
    method: 'get',
    response: ({ query }) => {
      const { type } = query;
      return resultSuccess(UnitJson, type);
    },
  },
  {
    url: '/mock-api/comUnit/getunittree/103645',
    timeout: 100,
    method: 'get',
    response: ({ query }) => {
      const { type } = query;
      return resultSuccess(TreeJson, type);
    },
  },
  {
    url: '/mock-api/comUnit/getParentid/103645',
    timeout: 100,
    method: 'get',
    response: ({ query }) => {
      const { type } = query;
      return resultSuccess(ParentJson, type);
    },
  },
  {
    url: '/mock-api/comRegion/getRegions/0',
    timeout: 100,
    method: 'get',
    response: () => {
      return resultSuccess(RegionsJson);
    },
  },
] as MockMethod[];
